<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*,com.tagfree.util.*,org.w3c.tidy.*,org.w3c.dom.*" %>
<%-- 
    JSP Name : nt_200_03.jsp
    Description : 이벤트관리등록.
    author Seung Won
    since 2012. 7. 19.
    version 1.0
    Modification Information
       since          author              description
    ===========    =============    ===========================
    2012. 7. 19.     Seung Won     최초 생성
--%>
<%@ include file="/WEB-INF/jsp/co/mn/include/declare.jspf" %>
<%@ include file="/WEB-INF/jsp/co/mn/include/session.jspf" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/WEB-INF/jsp/co/mn/include/header.jspf" %>
<script type="text/javascript" src="/dextuploadfl/DEXTUploadFL.js"></script>
<script type="text/javaScript" language="javascript">
<!--
$(document).ready(function() {    
    /* form validation check */
    onloadCharCheck();
    
    /* List Page 이동 */
    $("#listButn").bind("click", moveListPage);
    /* Form Submit */
    $("#rgstButn").bind("click", blcSubm);
    /* Form 초기화 */
    $("#cnclButn").bind("click", formIniz);
});

/*
 * 캘린더 제어
 */
$(function() {
    $( "#bulStrtDt" ).datepicker({
        showOn: "button",
        buttonImage: "/img/mng/ico/ico_calendar.gif",
        buttonImageOnly: true
    });

    $( "#bulFnhDt" ).datepicker({
        showOn: "button",
        buttonImage: "/img/mng/ico/ico_calendar.gif",
        buttonImageOnly: true
    });
});


/*
 * 리스트페이지 이동
 */
function moveListPage() {
    $("#mainForm").attr('action','/nt_200_01.do').submit();
}

/*
 * Form Submit
 */
function blcSubm() {
    if (!validateForm($("#mainForm"))) {
        return;
    }
    
    if ( !validateSearchDate($("#bulStrtDt").val(), $("#bulFnhDt").val()) ) {
        alert("검색기간을 다시 선택해주세요.");
        $("#bulStrtDt").focus();
        return false;
    }
    
    if (!isSchrChk($("#titl").val())) {
        alert("[제목] 은 특수문자(!#$%^&*|'<>-;)를 입력할 수 없습니다.");
        $("#title").focus();
        return;
    }
    
    if ( "${ptCnt}" != "0" ){
        if ("${result.evntScnCd}" != $("#evntScnCd").val()) {
            alert("구분값을 수정할수 없습니다.\신청 목록이 존재합니다.");
            return;
        }
    }
    
    if (document.twe.BodyValue == "<P style=\"FONT-FAMILY: gulim; FONT-SIZE: 9pt\"></P>") {
        alert("[내용] 을 입력해 주세요.");
        return;
    }
    
    $("#mime_contents").val(document.twe.MimeValue());
    $("#mainForm").attr('target','comIframe');
    
    <c:if test="${result.evntIdx  != null }">
    $("#mainForm").attr('action','/nt_200_05.do').submit();
    </c:if>
    <c:if test="${result.evntIdx  == null }">
    $("#mainForm").attr('action','/nt_200_04.do').submit();
    </c:if>
}

/*
 * Form 초기화
 */
function formIniz() {
    $("form").each(function(){
       this.reset(); 
    });
    
    <c:if test="${result.evntIdx  != null }">
    document.mainForm.twe.HtmlValue = document.mainForm.mime_contents.value;
    </c:if>
    <c:if test="${result.evntIdx  == null }">
    document.twe.BodyValue = "<P style=\"FONT-FAMILY: gulim; FONT-SIZE: 9pt\"></P>";
    </c:if>
}
//-->
</script>
<script language="JScript" FOR="twe" EVENT="OnControlInit()">
    var form = document.mainForm;
    form.twe.HtmlValue = form.mime_contents.value;
</script>
</head>
<body>
<div id="wrap">
    <!-- top -->
    <%@ include file="/WEB-INF/jsp/co/mn/include/top.jsp" %>
    <!-- top -->

    <!-- container -->
    <div id="container">
        <!-- LNB -->
        <%@ include file="/WEB-INF/jsp/co/mn/include/left.jsp" %>
        <!-- LNB -->
        
        <div id="contents">
            
            <!-- location -->
            <%@ include file="/WEB-INF/jsp/co/mn/include/location.jsp" %>
            <!-- location -->
            
            <p class="msgRequired"><span>*</span>표시는 필수 입력항목입니다</p>
            <form id="mainForm" name="mainForm" method="post" enctype="multipart/form-data">
            <%-- request --%>
                <input type="hidden" id="evntIdx" name="evntIdx" value="${result.evntIdx }" />
                <input type="hidden" id="currentPageNo" name="currentPageNo" value="${rqInfo.currentPageNo }" />
                <input type="hidden" id="srchScn" name="srchScn" value="${rqInfo.srchScn }" />
                <input type="hidden" id="srchTxt" name="srchTxt" value="${rqInfo.srchTxt }" />
                <input type="hidden" id="srchStrtDt" name="srchStrtDt" value="${rqInfo.srchStrtDt }" />
                <input type="hidden" id="srchFnhDt" name="srchFnhDt" value="${rqInfo.srchFnhDt }" />
                <input type="hidden" id="srchEvntScn" name="srchEvntScn" value="${rqInfo.srchEvntScn }" />
                <input type="hidden" id="srchScn" name="srchEvnt" value="${rqInfo.srchEvnt }" />
                <input type="hidden" id="srchScn" name="srchEvntOft" value="${rqInfo.srchEvntOft }" />
                <input type="hidden" id="mlgScnCd" name="mlgScnCd" value="KO" />
            <table border="1" class="frmTable" summary="공지&#47;이벤트의 제목,기간,상태,구분,첨부파일, 내용을 입력하는 표">
                <col width="25%" />
                <col width="40%" />
                <col width="15%" />
                <col width="15%" />
                <tbody>
                    <tr>
                        <th><sup>*</sup>기간</th>
                        <td>
                            <div class="dateSearch">
                                <input type="text" value="${result.bulStrtDt}" id="bulStrtDt" name="bulStrtDt" size="13" nullable="true" maxlength="10" readonly="readonly" title="시작일" />&nbsp;~&nbsp;<input type="text" value="${result.bulFnhDt}" id="bulFnhDt" name="bulFnhDt" nullable="true" maxlength="10" size="13" readonly="readonly" title="종료일" />
                            </div>
                        </td>
                        <th class="subThead">상태</th>
                        <td>
                            <select id="evntSt" name="evntSt">
                                <option value="01" <c:if test="${result.evntSt == '01' }"><c:out value="selected" /></c:if>>준비중</option>
                                <option value="02" <c:if test="${result.evntSt == '02' }"><c:out value="selected" /></c:if>>진행중</option>
                                <option value="03" <c:if test="${result.evntSt == '03' }"><c:out value="selected" /></c:if>>종료</option>
                            </select>
                        </td>
                    </tr>
                    <tr> 
                        <th><sup>*</sup>제목</th>
                        <td colspan="3"><input type="text" title="제목" maxlength="50" id="titl" name="titl" value="${result.titl }" nullable="true" minbyte="1" /></td>
                    </tr>
                    <tr>
                        <th><sup>*</sup>구분</th>
                        <td>
                            <select id="evntScnCd" name="evntScnCd">
                                <option value="01" <c:if test="${result.evntScnCd == '01' }"><c:out value="selected" /></c:if>>세잎클로버</option>
                                <option value="02" <c:if test="${result.evntScnCd == '02' }"><c:out value="selected" /></c:if>>사회복지 공모사업</option>
                                <option value="03" <c:if test="${result.evntScnCd == '03' }"><c:out value="selected" /></c:if>>H-volunteer Designer</option>
                                <option value="06" <c:if test="${result.evntScnCd == '06' }"><c:out value="selected" /></c:if>>H-Family Volunteer</option>
                                <option value="04" <c:if test="${result.evntScnCd == '04' }"><c:out value="selected" /></c:if>>오픈이벤트</option>
                                <option value="05" <c:if test="${result.evntScnCd == '05' }"><c:out value="selected" /></c:if>>기타</option>
                            </select>
                        </td>
                        <th class="subThead">정렬순서</th>
                        <td>
                            <select id="sortNum" name="sortNum" style="width:90px;">
                                <option value="1" <c:if test="${result.sortNum == 1 }"><c:out value="selected"/></c:if>>일반노출</option>
                                <option value="0" <c:if test="${result.sortNum < 1 }"><c:out value="selected"/></c:if>>우선노출</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>첨부파일</th>
                        <td colspan="3">
                            <div class="imgUpload">
                                <p><able:file name="attcFile" fixed="true" filename="" maxsize="30" sizeunit="M" sub="common" classType=""/></p>
                            </div>
                            <p class="attach"><span>[10MB이하]</span> hwp, doc, docx, ppt, pptx, ppts, xls, xlsx, txt 파일 업로드 가능</p>
                            <c:if test="${result.filNm != null }">
                            <div><a href="#" onclick="getUpFileDownload('0200','${result.evntIdx}');return false;">${result.filNm }</a></div>
                            </c:if>
                        </td>
                    </tr>
                    <tr id="trid">
                        <th><sup>*</sup>내용</th>
                        <td colspan="3">
                            <input type="hidden" id="mime_contents" name="mime_contents" title="내용" value="${result.sbc }" />
                            <script language="jscript" src="/editor/tweditor.js"></script>
                        </td>
                    </tr>
                </tbody>
            </table>
            </form>
            <div class="btnBoard">
                <span class="flow">
                    <input type="submit" id="listButn" title="목록" value="목록" />
                </span>
                <span class="reverse">
                    <c:if test="${result.evntIdx  != null }">
                    <input type="submit" id="rgstButn" title="수정" value="수정" />
                    </c:if>
                    <c:if test="${result.evntIdx  == null }">
                    <input type="submit" id="rgstButn" title="등록" value="등록" />
                    </c:if>
                    <input type="submit" id="cnclButn" title="취소" value="취소" />
                </span>
            </div>
        </div>
    </div>

            <!-- /container -->

    <!-- footer -->
    <%@ include file="/WEB-INF/jsp/co/mn/include/bottom.jsp" %>
    <!-- /footer -->
</div>
</body>
</html>